package com.daiTest.controller;

import com.daiTest.pojo.vo.PortalVo;
import com.daiTest.service.HeadlineService;
import com.daiTest.service.TypeService;
import com.daiTest.untils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("portal")
@CrossOrigin
public class ProtalController {

    @Autowired
    private TypeService typeService;

    @Autowired
    private HeadlineService headlineService;

    /*查询新闻类别栏*/
    @GetMapping("findAllTypes")
    public Result findAllTypes() {
        Result result = typeService.findAllTypes();
        return result;
    }

    /*客户端向服务端发送查询关键字,新闻类别,页码数,页大小
      服务端根据条件搜索分页信息,返回含页码数,页大小,总页
      数,总记录数,当前页数据等信息,并根据时间降序,浏览量降序排序*/
    @PostMapping("findNewsPage")
    public Result fingNewPage(@RequestBody PortalVo portalVo){
     Result result= headlineService.findNewPage(portalVo);
     return result;
    }

    /*根据新闻id 查看全文*/
    @PostMapping("showHeadlineDetail")
    public Result showHeadLineDetail(Integer hid){
        Result result=headlineService.showHeadLineDetail(hid);
        return result;
    }


}
